<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Announcements extends CI_Controller{
    function __construct(){
        parent::__construct();


    }

    public function index() {

        redirect('home');
    }


    public function getAnnouncements(){

        if(!$this->session->userdata('validated'))
        {
            redirect('home');
        }

        $query = $this->db->query("SELECT * FROM announcements");


        if ($query->num_rows() > 0)
        {
            $i=0;
            foreach ($query->result() as $row)
            {

                $data = array(
                    'title' => $row->title,
                    'content' => $row->content,
                    'date' => $row->date,
                    'time' => $row->time,
                    'category' => $row->category,
                    'author' => $row->author
                );
                $i++;
            }
        }
        $data['results'] = $query->result();

        $this->load->helper('url');
        $menu = 'navigation';
        $logged_in = $this->session->userdata('validated');
        if($logged_in==true)
        {
            $menu = 'navigation_logged';
        }
        $this->load->view('templates/header');
        $this->load->view('templates/'.$menu);
        $this->load->view('pages/announcements',$data);
        $this->load->view('templates/footer');
    }

}
?>